//
//  KFWNotificationProblemCommentCell.m
//  KWNLaywerClient
//
//  Created by 孔六五 on 15/1/28.
//  Copyright (c) 2015年 张明磊. All rights reserved.
//

#import "KFWNotificationProblemCommentCell.h"
#import "TQStarRatingView.h"
#import "Model_notificationProblem.h"

@implementation KFWNotificationProblemCommentCell
@synthesize imageview_unread;
@synthesize imageview_message;
@synthesize imageview_ren;
@synthesize label_name;
@synthesize label_fuwu;
@synthesize label_QuestionDetailType;
@synthesize label_QuestionType;
@synthesize label_text;
@synthesize label_time;
@synthesize label_xiangying;
@synthesize label_zhuangye;
@synthesize tq_fuwu;
@synthesize tq_xiangying;
@synthesize tq_zhuanye;
@synthesize imageview_line;

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        
        imageview_ren = [[UIImageView alloc] initWithFrame:CGRectMake(20, 13, 11, 15)];
        imageview_ren.image = [UIImage imageFileName:@"image_free_Person.png"];
        
        label_name = [UIUtils creatLabel];
        label_name.frame = CGRectMake(imageview_ren.frame.origin.x + imageview_ren.frame.size.width + 3, 13, 140, 15);
        label_name.font = FontOfHelveticaBold(13);
        label_name.textColor = RGB(206, 206, 206);
        
        imageview_message = [[UIImageView alloc] initWithFrame:CGRectMake(MainScreenWidth - 143, 10, 20, 19)];
        imageview_message.image = [UIImage imageFileName:@"image_qListType.png"];
        
        label_QuestionType = [UIUtils creatLabel];
        label_QuestionType.frame = CGRectMake(MainScreenWidth - 120, 13, 52, 15);
        label_QuestionType.textColor = RGB(134, 177, 217);
        label_QuestionType.font = FontOfHelveticaBold(13);;
        
        label_QuestionDetailType = [UIUtils creatLabel];
        label_QuestionDetailType.frame = CGRectMake(MainScreenWidth - 62, 13, 52, 15);
        label_QuestionDetailType.textColor = RGB(134, 177, 217);
        label_QuestionDetailType.font = FontOfHelveticaBold(13);
        
        imageview_unread = [[UIImageView alloc] initWithFrame:CGRectMake(6, 45, 8, 8)];
        //        imageview_unread.backgroundColor = RGB(219, 15, 31);
        imageview_unread.backgroundColor = [UIColor redColor];
        imageview_unread.hidden = YES;
        imageview_unread.layer.cornerRadius = 4;
        imageview_unread.clipsToBounds = YES;
        
        //响应速度
        label_xiangying = [UIUtils creatLabel];
        label_xiangying.font = FontOfHelveticaBold(15);
        label_xiangying.text = @"响应速度：";
        label_xiangying.textColor = ColorOfQuestionList;
        label_xiangying.frame = CGRectMake(20, 40, 75, 20);
        tq_xiangying = [[TQStarRatingView alloc] initWithCustomFrame:CGRectMake(20 + 75, 40, 120, 20) numberOfStar:5];
        //服务态度
        label_fuwu = [UIUtils creatLabel];
        label_fuwu.font = FontOfHelveticaBold(15);
        label_fuwu.text = @"服务态度：";
        label_fuwu.textColor = ColorOfQuestionList;
        label_fuwu.frame = CGRectMake(20, tq_xiangying.frame.origin.y + tq_xiangying.frame.size.height, 75, 20);
        
        tq_fuwu = [[TQStarRatingView alloc] initWithCustomFrame:CGRectMake(20 + 75, label_fuwu.frame.origin.y, 120, 20) numberOfStar:5];
        
        //专业程度
        label_zhuangye = [UIUtils creatLabel];
        label_zhuangye.font = FontOfHelveticaBold(15);
        label_zhuangye.text = @"专业程度：";
        label_zhuangye.textColor = ColorOfQuestionList;
        label_zhuangye.frame = CGRectMake(20, label_fuwu.frame.origin.y + label_fuwu.frame.size.height, 75, 20);
        tq_zhuanye = [[TQStarRatingView alloc] initWithCustomFrame:CGRectMake(20 + 75, label_zhuangye.frame.origin.y, 120, 20) numberOfStar:5];
        
        [tq_xiangying setUserInteractionEnabled:NO];
        [tq_fuwu setUserInteractionEnabled:NO];
        [tq_zhuanye setUserInteractionEnabled:NO];

        label_text = [UIUtils creatLabel];
        [label_text sizeToFit];
        label_text.numberOfLines = 0;
        label_text.font = FontOfQuestionList;
        label_text.frame = CGRectMake(20, 40, MainScreenWidth - 30, 20);
        label_text.textColor = ColorOfQuestionList;
        label_text.hidden = YES;
        
        label_time = [UIUtils creatLabel];
        label_time.font = FontOfSystem(13);
        label_time.frame = CGRectZero;
        label_time.textColor = RGB(194, 194, 194);
        
        imageview_line = [[UIImageView alloc] initWithFrame:CGRectZero];
        
        [self addSubview:imageview_ren];
        [self addSubview:label_name];
        [self addSubview:imageview_message];
        [self addSubview:label_QuestionType];
        [self addSubview:label_QuestionDetailType];
        [self addSubview:imageview_unread];
        [self addSubview:label_text];
        [self addSubview:label_time];
        [self addSubview:imageview_line];
        
        [self addSubview:label_xiangying];
        [self addSubview:tq_xiangying];
        [self addSubview:label_fuwu];
        [self addSubview:tq_fuwu];
        [self addSubview:label_zhuangye];
        [self addSubview:tq_zhuanye];

    }
    return self;
}

- (void)changeNotiProblemCommentCellWith:(Model_notificationProblemComments *)problemComment;
{
    NSInteger kind = problemComment.string_question_type.integerValue;
    NSArray *arr = [UIUtils getQuestionTypeWithkind:kind];
    label_QuestionType.text = arr[0];
    label_QuestionDetailType.text = arr[1];
    if ([problemComment.string_isunread integerValue] == 0) {
        imageview_unread.hidden = YES;
        label_text.textColor = RGB(162, 162, 162);
        label_xiangying.textColor = RGB(162, 162, 162);
        label_fuwu.textColor = RGB(162, 162, 162);
        label_zhuangye.textColor = RGB(162, 162, 162);

    }
    else
    {
        imageview_unread.hidden = NO;
        label_text.textColor = ColorOfQuestionList;
        label_xiangying.textColor = ColorOfQuestionList;
        label_fuwu.textColor = ColorOfQuestionList;
        label_zhuangye.textColor = ColorOfQuestionList;
    }

    [tq_xiangying setScore:problemComment.string_xy_fraction.floatValue/5.0 withAnimation:NO];
    [tq_fuwu setScore:problemComment.string_fw_fraction.floatValue/5.0 withAnimation:NO];
    [tq_zhuanye setScore:problemComment.string_zy_fraction.floatValue/5.0 withAnimation:NO];
    if (problemComment.string_content && problemComment.string_content.length >0) {
        label_text.frame = CGRectMake(20, label_zhuangye.frame.origin.y + label_zhuangye.frame.size.height + 10, MainScreenWidth - 30, 20);
        label_text.hidden = NO;
        label_text.text = problemComment.string_content;
        label_time.frame = CGRectMake(20, label_text.frame.origin.y + label_text.frame.size.height + 10, 200, 15);
    }
    else
    {
        label_text.frame = CGRectZero;
        label_text.hidden = YES;
        label_time.frame = CGRectMake(20, label_zhuangye.frame.origin.y + label_zhuangye.frame.size.height + 10, 200, 15);

    }
    label_time.text = problemComment.string_time;
    imageview_line.frame = CGRectMake(0, label_time.frame.origin.y + label_time.frame.size.height + 9, MainScreenWidth, 1);
    imageview_line.backgroundColor = RGB(220, 220, 220);
}

@end
